﻿// Decompiled with JetBrains decompiler
// Type: XamlEditor.TreeViewEditor
// Assembly: XamlEditor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 2AF0471B-7BFE-4738-893B-A4F91E243353
// Assembly location: C:\Users\KasimGulcan\Desktop\Kosgeb\DynaCAD\Project\lib\XamlEditor.dll

using System;
using System.Collections;
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace XamlEditor
{
  public static class TreeViewEditor
  {
    public static void TreeViewOfCanvas(Canvas x, TreeView TV)
    {
      int i = 0;
      TV.Items.Clear();
      TreeViewItem TVI = new TreeViewItem();
      TVI.Header = (object) "Main_Canvas";
      TVI.Name = "A";
      TVI.IsExpanded = true;
      Enumerable.ToList<UIElement>(Enumerable.OfType<UIElement>((IEnumerable) x.Children)).ForEach((Action<UIElement>) (U =>
      {
        TreeViewItem TV1 = new TreeViewItem();
        TVI.Items.Add((object) TV1);
        TV1.Header = (object) Convert.ToString((object) U.GetType());
        TV1.Name = ((FrameworkElement) TV1.Parent).Name + "_" + Convert.ToString(i);
        TV1.IsExpanded = true;
        if (Convert.ToString((object) U.GetType()) == "System.Windows.Controls.Canvas")
          TreeViewEditor.AddItem(TV1, U);
        ++i;
      }));
      TV.Items.Add((object) TVI);
    }

    public static void AddItem(TreeViewItem TV, UIElement x)
    {
      int i = 0;
      Enumerable.ToList<UIElement>(Enumerable.OfType<UIElement>((IEnumerable) ((Panel) x).Children)).ForEach((Action<UIElement>) (U =>
      {
        TreeViewItem TV1 = new TreeViewItem();
        TV.Items.Add((object) TV1);
        TV1.Header = (object) Convert.ToString((object) U.GetType());
        TV1.Name = ((FrameworkElement) TV1.Parent).Name + "_" + Convert.ToString(i);
        TV1.IsExpanded = true;
        if (Convert.ToString((object) U.GetType()) == "System.Windows.Controls.Canvas")
          TreeViewEditor.AddItem(TV1, U);
        ++i;
      }));
    }
  }
}
